<?php
namespace AppHome\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function __construct()
    {
        parent::__construct();
        $this->check_login();

    }

    /*APP提交功能首页*/
    public function index(){
        $this->display();
    }

    public function logout(){
        unset($_SESSION['user']);
        $this->display();
    }

    public function check_login(){
         if(!$_SESSION['user']){
             $this->redirect(U('user/login'));
         }
    }

    /*开始任务数据入库操作*/
    public function upload_start(){
        $m = M('upload');
        $data = I('post.');
        $result = $m->add($data);
        if($result){
            echo json_encode(array('status'=>1,'msg'=>'操作成功！'));
            die();
        }else{
            echo json_encode(array('status'=>0,'msg'=>'操作失败！'));
            die();
        }
    }
    /*接受图片验证后返回，可多次调用*/
    public function validate(){
		
        //$result = $this->doupimgs();
     //   echo json_encode($result);exit;
        /*调用API的URL地址*/
        //$url = 'http://localhost:5000/todo/api/v1.0/dashbaord_oil/'.$result['img_path'];
		$url = 'http://127.0.0.1:5000/todo/api/v1.0/dashbaord_oil/timg.jpg';
        $curl_data = $this->curl_post($url,$result);
		var_dump($curl_data);
    }

}